<template>
	<view>
		<view class="yile_address">
			<view class="con" v-for="(item,index) in list" :key="index"
				@click="funHref('/pages/my/address/address_edit?id='+item.ma_id)">
				<!-- <text class="edit">编辑</text> -->
				<view>
					<text>{{item.ma_name}}<label>{{item.ma_phone}}</label></text>
					<label>{{item.ma_address}}</label>
				</view>
			</view>
		</view>
		<!--空信息-->
		<view class="nodata_con" v-if="isLoading==false&&list.length<=0">
			<label class="iconfont icon-meiyoushuju"></label>
			<text>{{$t('no_data')}}</text>
		</view>
		<view class="btn_pop" @click="funHref('/pages/my/address/address_add')">
			{{$t('add_address')}}
		</view>
		<!--刷新-->
		<view class='loadind_con' v-if="isLoading">
			<view class="loading">
				<view class="loading-bar"></view>
				<view class="loading-bar"></view>
				<view class="loading-bar"></view>
				<view class="loading-bar"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				index: 1, //页数
				size: 10, //条数
				list: [], //列表值
				isLoading: true, //是否正在加载
			}
		},
		onReady() {
			uni.setNavigationBarTitle({
				title: this.$t('address')
			})
		},
		onLoad() {
			var _this = this;
			//加载列表
			_this.getData();

			//定义通讯方法
			uni.$on('load_list_address', function(data) {
				_this.index = 1;
				_this.list = [];
				_this.isLoading = true;
				_this.getData();
			});
		},
		onUnload() {
			uni.$off("load_list_address");
		},
		onPullDownRefresh() { //下拉刷新
			var _this = this;
			//清空还原
			_this.index = 1;
			_this.list = [];
			_this.isLoading = true;
			_this.getData();
		},
		onReachBottom() { //上拉到底部刷新
			var _this = this;
			_this.index = _this.index + 1;
			_this.isLoading = true;
			_this.getData();
		},
		methods: {
			getData: function() { //获取内容
				var _this = this;
				_this.fun_request("/Api/MemberAddress/GetPageList", {
					index: _this.index,
					size: _this.size,
					count: 0
				}, function(res) {
					var _list = res.data;
					_this.list = _this.list.concat(_list);
					//加载完成
					_this.isLoading = false;
					//下拉刷新 - 停止
					uni.stopPullDownRefresh();
				});
			},
			funHref: function(url) { //跳转
				this.fun_navigateTo(url);
			},
		}
	}
</script>

<style>
	page {
		background: #F7F7F7;
	}

	.yile_address {
		width: 100%;
		font-size: 30rpx;
	}

	.yile_address view.con {
		width: 100%;
		border-bottom: 1px solid #eee;
		padding: 35rpx 0 30rpx 3%;
		background-color: #fff;
	}

	.yile_address view.con view {
		display: block;
		padding-right: 30rpx;
	}

	.yile_address view.con view label {
		max-height: 100%;
		font-size: 28rpx;
		color: #999;
		display: block;
	}

	.yile_address view.con view text {
		font-size: 30rpx;
		display: block;
		margin-bottom: 5rpx;
	}

	.yile_address view.con view text label {
		font-size: 30rpx;
		color: #999;
		margin-left: 20rpx;
		display: inline-block;
	}

	.yile_address view.con text.edit {
		float: right;
		font-size: 32rpx;
		height: 80rpx;
		line-height: 40rpx;
		border-left: 1px solid #ccc;
		color: #999;
		width: 50rpx;
		text-align: right;
	}
</style>
